(function($){

var tabbase = "";
/* Fetch the domain of the current tab */
chrome.tabs.getSelected(null,function(tab) {
	var re = new RegExp('^((?:f|ht)tp(?:s)?\://([^/]+))', 'im');
	tabbase = tab.url.match(re)[1].toString();
	pageLoad();
});
		
function pageLoad() {
	$(function(){
		/* Let's setup these links */
		$(".tablink").click(function(){
			var linkurl = tabbase + $(this).attr("href");
			window.open(linkurl, "_blank");
			return false;
		});

		/* Let's get the version number and license info if possible */
		$.get(tabbase + "/sitecore/login", function(data){
			$('#responseDiv').html(data);
			$('#myVersionInfo').append($('#responseDiv').find('#SystemInformation'));
		});
	});
}

})(jQuery);
